package com.vcredit.bird.monitor;

import java.lang.reflect.Method;

public class ExceptionHandlerProxy {

	private MonitorExceptionHandler monitorExceptionHandler;

	private Method proxyMethod;

	private SendMonitorMessage sender;

	public ExceptionHandlerProxy() {
		super();
	}

	public ExceptionHandlerProxy(MonitorExceptionHandler monitorExceptionHandle, Method method,
			SendMonitorMessage sender) {
		super();
		this.monitorExceptionHandler = monitorExceptionHandle;
		this.proxyMethod = method;
		this.sender = sender;
	}

	public void handleException(String methodDesc, Exception e, Method method) throws Exception {
		Message message = (Message) proxyMethod.invoke(monitorExceptionHandler, new Object[] { methodDesc, e, method });
		sender.sendMessage(message);
	}

	public MonitorExceptionHandler getMonitorExceptionHandler() {
		return monitorExceptionHandler;
	}

	public void setMonitorExceptionHandler(MonitorExceptionHandler monitorExceptionHandler) {
		this.monitorExceptionHandler = monitorExceptionHandler;
	}

	public Method getMethod() {
		return proxyMethod;
	}

	public void setMethod(Method proxyMethod) {
		this.proxyMethod = proxyMethod;
	}

	public SendMonitorMessage getSender() {
		return sender;
	}

	public void setSender(SendMonitorMessage sender) {
		this.sender = sender;
	}
}
